package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
/**产品类型实体类*/
@Entity
public class Productcategory {
    private int pcId;
    private String pcName;
    private Integer pcHigherid;
    private Integer pcLevel;
    private List<Productbrand> productbrand;//类型对应多个品牌
    private Productbrand brank;//多个类型对应一个品牌
    private Collection<Products> productsByPcId;

    @OneToMany(mappedBy = "productcategory")
    public List<Productbrand> getProductbrand() {
        return productbrand;
    }

    @ManyToOne
    @JoinColumn( name ="pbId", referencedColumnName="Pb_id")
    public Productbrand getBrank() {
        return brank;
    }

    public void setBrank(Productbrand brank) {
        this.brank = brank;
    }

    public void setProductbrand(List<Productbrand> productbrand) {
        this.productbrand = productbrand;
    }

    @Id
    @Column(name = "Pc_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getPcId() {
        return pcId;
    }

    public void setPcId(int pcId) {
        this.pcId = pcId;
    }

    @Basic
    @Column(name = "Pc_name")
    public String getPcName() {
        return pcName;
    }

    public void setPcName(String pcName) {
        this.pcName = pcName;
    }

    @Basic
    @Column(name = "Pc_higherid")
    public Integer getPcHigherid() {
        return pcHigherid;
    }

    public void setPcHigherid(Integer pcHigherid) {
        this.pcHigherid = pcHigherid;
    }

    @Basic
    @Column(name = "Pc_level")
    public Integer getPcLevel() {
        return pcLevel;
    }

    public void setPcLevel(Integer pcLevel) {
        this.pcLevel = pcLevel;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Productcategory that = (Productcategory) o;
        return pcId == that.pcId &&
                Objects.equals(pcName, that.pcName) &&
                Objects.equals(pcHigherid, that.pcHigherid) &&
                Objects.equals(pcLevel, that.pcLevel);
    }

    @Override
    public int hashCode() {
        return Objects.hash(pcId, pcName, pcHigherid, pcLevel);
    }

    @OneToMany(mappedBy = "productcategoryByPcId")
    public Collection<Products> getProductsByPcId() {
        return productsByPcId;
    }

    public void setProductsByPcId(Collection<Products> productsByPcId) {
        this.productsByPcId = productsByPcId;
    }
}
